'''
Created on 2016年12月20日

@author: maliqiang
'''
#字典（map）
dict = {'name':'mark','age':'20'}
print('字典输出：',dict['name'])

#对列表进行排序输出
m=['makr','jerry','tony']
m.sort(key=None, reverse=False)
for s in range(0,len(m)):
    print(m[s])
    
#列表反转输出
m.reverse()
for j in range(0,len(m)):
    print(m[j])

#解析列表
M = [[1,2,3],[4,5,6],[7,8,9]]
diag = [M[i][i] for i in [0,1,2]]
print(diag)

#按照行分组求和
G = (sum(row) for row in M)
n = next(G)
print(n)
print(next(G))


#while循环
i =0
while i<100:
    i=i+5
    print(i)

#模拟登陆过程
print('请输入用户名：')
name = input()
if name=='admin':
    print('欢迎你'+name+',login success')
else:
    print('error')

#正则匹配
import re
line = "Cats are smarter than dogs"
matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I)

if matchObj:
    print ("matchObj.group(0):", matchObj.group())
    print ("matchObj.group(1): ", matchObj.group(1))
    print ("matchObj.group(2): ", matchObj.group(2))
else:
    print ("No match!!")
    